package com.csun.cmny.provider.service.impl;

import com.csun.cmny.base.dto.LoginAuthDto;
import com.csun.cmny.core.support.BaseService;
import com.csun.cmny.provider.dao.OmcWelfareActivityCarouselMapper;
import com.csun.cmny.provider.model.domain.OmcWelfareActivityCarousel;
import com.csun.cmny.provider.service.OmcWelfareActivityCarouselService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;

@Slf4j
@Service
@Transactional
public class OmcWelfareActivityCarouselServiceImpl extends BaseService<OmcWelfareActivityCarousel> implements OmcWelfareActivityCarouselService {

    @Resource
    private OmcWelfareActivityCarouselMapper omcWelfareActivityCarouselMapper;

    @Override
    public int saveActivityCarousel(String picString, LoginAuthDto loginAuthDto) {

        OmcWelfareActivityCarousel acQuery = new OmcWelfareActivityCarousel();
        acQuery.setGroupId(loginAuthDto.getGroupId());
        acQuery = selectOne(acQuery);
        if(acQuery == null){
            acQuery = new OmcWelfareActivityCarousel();
            acQuery.setPicId(picString);
            acQuery.setGroupId(loginAuthDto.getGroupId());
            acQuery.setUpdateInfo(loginAuthDto);
            return save(acQuery);
        }else{
            acQuery.setPicId(picString);
            return update(acQuery);
        }
    }
}
